#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
/*
 * Zenlayer.com Inc.
 * Copyright (c) 2014-2021 All Rights Reserved.
 */
package ${package}.${artifactId}.config.amqp.callback;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.${artifactId}.RabbitTemplate.ConfirmCallback;

/**
 * @author wangjunjie
 * @version ${symbol_dollar} Id: RabbitConfirmCallback.java, v 0.1  wangjunjie Exp ${symbol_dollar}
 * @date 2019-09-18 15:09:45
 */
public class RabbitConfirmCallback implements ConfirmCallback {

    private static final Logger logger = LoggerFactory.getLogger(RabbitConfirmCallback.class);

    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String failCause) {
        //ack结果为true，表明正常接收到了消息
//        if (!ack) {
//            logger.error("correlationData:" + correlationData + ",ack:" + ack + ",cause:" + ack);
//        }

        if (ack) {
            logger.info("消息发送成功");
        } else {
            logger.error("消息发送失败，进行容错处理");
        }
        logger.info("消息发送到交换机时的回调函数, ack：" + ack + "FailCause 消息：" + failCause);
    }
}
